home *** CD-ROM | disk | FTP | other *** search
- struct Knoten {
- long Schluessel, Info;
- struct Knoten *Left,*Right;
- };
- struct Knoten *Kopf, *Ende;
- void Init()
- {
- Kopf=(struct Knoten *)malloc(sizeof(struct Knoten));
- Ende=(struct Knoten *)malloc(sizeof(struct Knoten));
- Kopf->Right = Ende; Kopf->Schluessel=0;
- Ende->Left=Ende; Ende->Right=Ende; Ende->Info = -1;
- }
- void Einfuegen( long schluessel, long info)
- {
- struct Knoten *a,*b:
- a=Kopf; b=Kopf->Right;
- while( b != Ende ) {
- a=b; b=(schluessel < b->Schluessel) ? b->Left : b->Right;
- }
- b=(struct Knoten *)malloc(sizeof(struct Knoten));
- b->Schluessel=schluessel; b->Info=info; b->Left=Ende;
- b->Right=Ende;
- if( schluessel < a->Schluessel )
- a->Left=b;
- else
- a->Right=b;
- }
- long Suchen(long schluessel)
- {
- struct Knoten *a=Kopf->Right;
- Ende->Schluessel=schluessel;
- while( schluessel != a->Schluessel )
- a=(schluessel < a->Schluessel) ? a->Left : a->Right;
- return a->Info;
- }
-
-